from  com.BookRepository import BookRepository
from com.PageList import PageList
class BookService(object):
    def __init__(self, app):
        self.app = app
        self.repository = BookRepository(app.config['database']['uri'])

    def add(self, name, author, price):
        return self.repository.add(name, author, price)

    def get(self, page, size, name):
        books = self.repository.list(page, size, name)
        count = self.repository.count(name)
        return PageList(count, books)
